<template>
  <div>
    <el-button type="primary" @click="selectPersonDialog = true" round>
      <el-icon><i-ep-plus /></el-icon>选择抄送人</el-button>
    <div class="option">
      允许发起人添加抄送人:
      <el-switch v-model="config.shouldAdd" />
    </div>
    <div style="margin-top: 20px">
      <el-tag
        class="item"
        v-for="(item, index) in select"
        :key="index" closable size="small"
        @close="removeOrgItem(index)"
      >
        {{ item.nickname }}
      </el-tag>
    </div>
    <v-select-person-dialog title="请选择抄送人" v-model="selectPersonDialog" @selectPerson="selectPerson"></v-select-person-dialog>

  </div>
</template>

<script>
export default {
  name: "CNodeConfig.vue",
  props: {
    config: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  computed: {
    select() {
      return this.config.assignedUser || [];
    },
  },
  data() {
    return {
      selectPersonDialog: false,
    };
  },
  methods: {
    selectPerson(personList) {
      this.select.splice(0, this.select.length);
      personList.forEach((val) => this.select.push(val));
    },
    removeOrgItem(index) {
      this.select.splice(index, 1);
    },
  },
};
</script>

<style lang="scss" scoped>
.option {
  color: #606266;
  margin-top: 20px;
  font-size: small;
}

.desc {
  font-size: small;
  color: #8c8c8c;
}
.item {
  margin: 5px;
}
</style>
